﻿/*
 * @Autor: PK
 */

using System;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Data.SQLite;
using FreeSql;
using MySql.Data.MySqlClient;
using ShkSimulation.core.dao.input.resource;

namespace ShkSimulation.core.dao.input.loader {
	
	public class DatabaseResourceLoader : ResourceLoader {
		
		private IFreeSql FreeSql;
		DbDataAdapter adapter = new SQLiteDataAdapter();

		public DatabaseResourceLoader(DataType dataType, string url) {
			SqlConnection MyConnection =new SqlConnection(url);
			SqlCommand MyCommand = new SqlCommand("SELECT * FROM data", MyConnection);
			adapter.SelectCommand = MyCommand;
			FreeSql = new FreeSqlBuilder()
				.UseConnectionString(dataType, url)
				.UseAutoSyncStructure(true)
				.Build();
		}

		public Resource LoadData(string uniqueKey, string tableName) {
			SqlConnection MyConnection = new SqlConnection("");
			SqlCommand MyCommand = new SqlCommand("SELECT * FROM data", MyConnection);
			DataSet dataSet = new DataSet();
			SQLiteDataAdapter adapter = new SQLiteDataAdapter();
			DataAdapter dataAdapter = new MySqlDataAdapter();
			dataAdapter.Fill(dataSet);
			DataTableCollection table = dataSet.Tables;
			return null;
		}

		public bool SaveData(Resource resource, string resourceInfo = null) {
			throw new NotImplementedException();
		}
	}
}